package com.chaodriod.common.system;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;

import com.chaodriod.common.utils.ALog;

/**
 * Created by CHEN on 2018-3-6.
 */

public class AppInstallReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        PackageManager manager = context.getPackageManager();
        if (intent.getAction().equals(Intent.ACTION_PACKAGE_ADDED)) {
            String packageName = intent.getData().getSchemeSpecificPart();
            ALog.e("安装成功:" + packageName);
        }
        if (intent.getAction().equals(Intent.ACTION_PACKAGE_REMOVED)) {
            String packageName = intent.getData().getSchemeSpecificPart();
            ALog.e("卸载成功:" + packageName);
        }
        if (intent.getAction().equals(Intent.ACTION_PACKAGE_REPLACED)) {
            String packageName = intent.getData().getSchemeSpecificPart();
            ALog.e("替换成功:" + packageName);
        }
        if (intent.getAction().equals(Intent.ACTION_MY_PACKAGE_REPLACED)) {
            String packageName = intent.getData().getSchemeSpecificPart();
            ALog.e("替换成功:" + packageName);
        }

    }

}
